package com;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

public class MyTest {
    private Integer i = null;
    @Test
    public void test(){
        int j = i;
        Integer.parseInt("aa");
    }

    @Test
    public void unboxingTest() {
        Integer i1 = 17;
        Integer i2 = 17;

        Integer i3 = 137;
        Integer i4 = 137;
        i1.intValue();
        Integer a = new Integer(1);

        System.out.println(i1 == i2);
        System.out.println(i3 == i4);

        System.out.println(i1.equals(i2));
        System.out.println(i3.equals(i4));

        String aa = null;
        aa.equals("mafly");
    }

    public static void main(String[] args) {
        List<String> a = new ArrayList<>();
        a.add("1");
        a.add("2");
        a.add("3");
        a.add("4");
        for (String temp : a) {
            if ("3".equals(temp)) {
                a.remove(temp);
            }
        }
        Iterator<String> it = a.iterator();
        while (it.hasNext()) {
            String temp = it.next();
            if ("2".equals(temp)) {
                it.remove();
            }
        }
    }

    @Test
    public void test2(){
        String[] a = new String[]{"1", "2"};
        List list = Arrays.asList(a);
        list.add("3");
    }

    @Test
    public void test3(){
        List<String> a = new ArrayList<>();
        a.add("1");
        a.add("2");
        String[] array = new String[a.size()];
        array = a.toArray(array);
    }

    @Test
    public void test4(){
        List<String> a = new ArrayList<>();
        a.add("1");
        a.add("2");
        List b = a.subList(1,2);
        b.add("3");
        a.add("4");
        System.out.println(a);
        System.out.println(b.size());
        System.out.println(b.toArray());
    }

    public void test9(){
        HashMap map = new HashMap();
    }

}
